﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>SlideBar - Events</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="stylesheet" href="../../../css/samples.css" />
    <link rel="stylesheet" href="../../../css/integralui.slidebar.css" />
    <link rel="stylesheet" href="../../../css/themes/theme-flat-blue.css" />
    <script type="text/javascript" src="../../../external/angular.min.js"></script>
    <script type="text/javascript" src="../../../js/angular.integralui.min.js"></script>
    <script type="text/javascript" src="../../../js/angular.integralui.slidebar.min.js"></script>
    <script type="text/javascript">
 		angular
			.module("appModule", ["integralui"])
			.controller("appCtrl", ["$scope", "IntegralUISlideBarService", "$timeout", function($scope, $ctrlService, $timeout){
                $scope.ctrlName = "ctrlSample";
                $scope.ctrlEnabled = true;
                $scope.slides = [
                    { id: 1, name: 'Slide1', text: 'Slide 1' },
                    { id: 2, name: 'Slide2', text: 'Slide 2' },
                    { id: 3, name: 'Slide3', text: 'Slide 3' }
                ];
                
                $scope.eventLog = [];
                
                $scope.onSlideChanging = function(e){
                    $scope.eventLog.unshift({ name: "slideChanging", info: " event was fired when current slide is about to change: ", value: e.slide.text }); 
                }
                
                $scope.onSlideChanged = function(e){
                    $scope.eventLog.unshift({ name: "slideChanged", info: " event was fired when current slide is changed: ", value: e.slide.text }); 
                }

                $scope.onButtonClicking = function(e){
                    $scope.eventLog.unshift({ name: "buttonClicking", info: " event was fired when navigation button is clicked, but before slide is changed." }); 
                }
                
                $scope.onButtonClicked = function(e){
                    $scope.eventLog.unshift({ name: "buttonClicked", info: " event was fired when navigation button is clicked and after slide changes." }); 
                }
                
                $scope.onEnabledChanged = function(e){
                    $scope.eventLog.unshift({ name: "enabledChanged", info: " event was fired when SlideBar becomes enabled or disabled, enabled property value set to: ", value: e.enabled }); 
                }
                
                $scope.ctrlEvents = {
                    slideChanging: function(e){
                        return $scope.onSlideChanging(e);
                    },
                    slideChanged: function(e){
                        return $scope.onSlideChanged(e);
                    },
                    buttonClicked: function(e){
                        return $scope.onButtonClicked(e);
                    },
                    buttonClicking: function(e){
                        return $scope.onButtonClicking(e);
                    },
                    enabledChanged: function(e){
                        return $scope.onEnabledChanged(e);
                    }
                }

                $scope.clearEventLog = function(){
                    $scope.eventLog.length = 0;
                }
		}]);
    </script>
    <style type="text/css">
        .directive
        {
            height: 300px;
        }
        .slide-content
        {
            padding: 30% 10px;
            font-size: 2em;
            text-align: center;
        }
        .slide-content-disabled
        {
            color: gray;
            padding: 30% 10px;
            font-size: 2em;
            text-align: center;
        }
        .event-panel
        {
            margin-top: 20px;
            width: 600px;
        }
        .event-block
        {
            width: 600px;
            height: 200px;
        }
        .event-log
        {
            height: 168px;
        }
    </style>
</head>
<body>
	<div class="header">
        <div class="header-content">
		    <h1><span style="color:#c60d0d">IntegralUI</span> Studio <span style="font-size:0.75em; font-style:italic">for Web</span></h1>
        </div>
        <hr class="head-separator" />
    </div>
    <div class="content" ng-app="appModule">
        <div class="feature" ng-controller="appCtrl">
	        <h2 class="feature-title">SlideBar / Events</h2>
	        <div class="feature-content">
                <iui-slidebar name="{{ctrlName}}" class="directive" slides="slides" events="ctrlEvents" animation-speed="slow" enabled="ctrlEnabled">
                    <iui-slide ng-repeat="slide in slides" name="{{slide.name}}">
                        <div ng-class="ctrlEnabled ? 'slide-content' : 'slide-content-disabled'">
                            {{slide.name}}
                        </div>
                    </iui-slide>
                </iui-slidebar>
                <div class="control-panel" align="center" style="width:150px">
                    <label><input type="checkbox" ng-model="ctrlEnabled" /> Enabled</label><br />
                </div>
                <br style="clear:both;"/>
                <div class="event-panel">
                    <div class="event-block">
                        <button type="button" ng-click="clearEventLog()" style="float:right;margin:3px 12px; width:50px">Clear</button>
                        <p style="margin:0 10px; padding: 3px; border-bottom: thin solid #c5c5c5">Event log:</p>
                        <ul class="event-log">
                            <li ng-repeat="ev in eventLog"><span class="event-name">{{ev.name}}</span>{{ev.info}}<span class="event-value">{{ev.value}}</span></li>
                        </ul>
                    </div>
                </div>
                <br style="clear:both;"/>
                <div class="feature-help">
                    <p><span class="initial-space"></span>This sample presents most of events that are fired from SlideBar directive. Depending on action, a specific event is fired, which you can handle by simple creating an event handler. Here is list of events that are supported:</p>
                     <ul class="feature-points">
                        <li><span style="color:#c60d0d">buttonClicking</span> - Occurs when navigation button is clicked, but before slide is changed</li>
                        <li><span style="color:#c60d0d">buttonClicked</span> - Occurs when navigation button is clicked and after slide changes</li>
                        <li><span style="color:#c60d0d">clear</span> - Occurs when slide list is cleared</li>
                        <li><span style="color:#c60d0d">enabledChanged</span> - Occurs when control is enabled or disabled</li>
                        <li><span style="color:#c60d0d">slideAdding</span> - Occurs before a new slide is added</li>
                        <li><span style="color:#c60d0d">slideAdded</span> - Occurs after a new slide is added</li>
                        <li><span style="color:#c60d0d">slideChanging</span> - Occurs when currently selected slide is about to change</li>
                        <li><span style="color:#c60d0d">slideChanged</span> - Occurs when currently selected slide is changed</li>
                        <li><span style="color:#c60d0d">slideRemoving</span> - Occurs before slide is removed</li>
                        <li><span style="color:#c60d0d">slideRemoved</span> - Occurs after slide is removed</li>
                        <li><span style="color:#c60d0d">styleChanged</span> - Occurs when control style has changed</li>
                    </ul>
                    <p><span class="initial-space"></span>Depending on some conditions, when handling some of above events you can prevent the default action to proceed, by canceling the operation.</p>
                    <p><span class="initial-space"></span>In this sample event log will not register add/remove events, because this kind of operation is not demonstrated here.</p>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
